﻿using System;
using System.IO;
using System.Reflection;


namespace DssLoader
{
	public class HostLoader
	{
		public static int Main(string[] args)
		{
			Assembly dssHost = Assembly.LoadFile(
				Path.Combine(
					Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
					"dsshost.exe"));
			if (dssHost != null)
			{
				Type hostType = dssHost.GetType("Microsoft.Dss.Hosting.CommandLine.RuntimeHost");
				if (hostType != null)
				{
					MethodInfo mainMethod = hostType.GetMethod("Main", BindingFlags.NonPublic | BindingFlags.Static);
					if (mainMethod != null)
						return (int) mainMethod.Invoke(null, new object[]{args});
				}
			}
			return 1;
		}
	}
}
